package com.example.datamanage.controller;

import com.example.datamanage.common.Result;
import com.example.datamanage.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 28142
 * @description 角色管理 controller
 * @date 2023/7/23 15:18
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    /**
     * 查询所有角色
     * @author 杨雨盛
     * @date 2023/7/23 15:20
     * @return com.example.datamanage.common.Result
     */
    @GetMapping
    public Result findAll() {
        return Result.success(roleService.list());
    }

    /**
     * 根据id查找角色
     * @author 杨雨盛
     * @date 2023/7/23 15:22
     * @param id
     * @return com.example.datamanage.common.Result
     */
    @GetMapping("/{id}")
    public Result findById(@PathVariable Integer id) {
        return Result.success(roleService.getById(id));
    }
}
